Imports System.IO

Public Class clsLogData
    Public Shared RunRecordSet As System.Data.DataSet

    Public Shared Sub AddRunRecord(ByVal FileName As String, ByVal SuccessType As String)
        If RunRecordSet Is Nothing Then
            InitSharedClass()
        End If

        Dim dt As DataTable = RunRecordSet.Tables("RunRecords")
        Dim dr As DataRow = dt.NewRow()
        Dim FileSize As Integer, MyFile As New FileInfo(FileName)
        If MyFile.Exists = True Then
            FileSize = MyFile.Length
        End If
        dr("FileName") = FileName
        dr("FileSize") = FileSize
        dr("SuccessType") = SuccessType
        dr("TimeStamp") = DateTime.Now
        dt.Rows.Add(dr)
    End Sub

    Public Shared Sub AddRunRecord(ByVal FileName As String, ByVal SuccessType As String, ByVal PageCount As Integer)
        If RunRecordSet Is Nothing Then
            InitSharedClass()
        End If

        Dim dt As DataTable = RunRecordSet.Tables("RunRecords")
        Dim dr As DataRow = dt.NewRow()
        Dim FileSize As Integer, MyFile As New FileInfo(FileName)
        If MyFile.Exists = True Then
            FileSize = MyFile.Length
        End If
        dr("FileName") = FileName
        dr("FileSize") = FileSize
        dr("SuccessType") = SuccessType
        dr("TimeStamp") = DateTime.Now
        dr("PageCount") = PageCount
        dt.Rows.Add(dr)
    End Sub

    Public Shared Sub InitSharedClass()
        RunRecordSet = New DataSet("RunRecordSet")
        Dim dt As New DataTable("RunRecords")
        dt.Columns.Add("FileName", System.Type.GetType("System.String"))
        dt.Columns.Add("FileSize", System.Type.GetType("System.Int32"))
        dt.Columns.Add("SuccessType", System.Type.GetType("System.String"))
        dt.Columns.Add("TimeStamp", System.Type.GetType("System.DateTime"))
        dt.Columns.Add("PageCount", System.Type.GetType("System.Int32"))
        RunRecordSet.Tables.Add(dt)
    End Sub

    Public Shared Sub SaveDataSet(ByVal FileName As String)
        RunRecordSet.WriteXml(FileName)
    End Sub

End Class
